home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbauxr.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-12-06  |  4.9 KB  |  124 lines

  1. (*===========================================================================*)
  2. (* Check for ring                                                            *)
  3. (*                                                                           *)
  4. (*   Copyright 1989, 1990 by H. Roy Engehausen.  All rights reserved.        *)
  5. (*   This software may be freely distributed and used, but it may not        *)
  6. (*   under any circumstances be sold by anyone other than the author.        *)
  7. (*   It may be distributed by a commercial company as long as it is          *)
  8. (*   for no cost.                                                            *)
  9. (*                                                                           *)
  10. (*===========================================================================*)
  11.  
  12. PROCEDURE check_ring;
  13.  
  14.   VAR
  15.     i           : BYTE;
  16.     new_tcb     : tcb_ptr;
  17.     prefix      : STRING[4];
  18.     thing       : STRING[10];
  19.  
  20.   BEGIN;
  21.  
  22.  
  23.     IF active_port^.connected^[1] <> NIL THEN
  24.       EXIT;
  25.  
  26.     active_port^.modem_dial := FALSE;
  27.  
  28.     (*-----------------------------------------------------------------------*)
  29.     (* Set speed as necessary                                                *)
  30.     (*-----------------------------------------------------------------------*)
  31.  
  32.     IF do_speed THEN
  33.       BEGIN;
  34.         do_speed := FALSE;
  35.         IF active_port^.data_rate <> active_port^.cur_rate THEN
  36.           FOR i := 1 TO 2 DO
  37.             cmd_tnc(@disc_cmd, TRUE);
  38.       END;
  39.  
  40.     (*-----------------------------------------------------------------------*)
  41.     (* Ready the display prefix                                              *)
  42.     (*-----------------------------------------------------------------------*)
  43.  
  44.     prefix := active_tcb^.port_chan_s + ' :';
  45.     IF active_tcb^.tnc_type = t_to_h_links THEN
  46.       prefix[3] := '-'
  47.     ELSE
  48.       prefix[3] := '<';
  49.  
  50.     (*-----------------------------------------------------------------------*)
  51.     (* Set time out for the data                                             *)
  52.     (*-----------------------------------------------------------------------*)
  53.  
  54.     active_port^.cr_timeout := 3;
  55.  
  56.     (*-----------------------------------------------------------------------*)
  57.     (* Get the data                                                          *)
  58.     (*-----------------------------------------------------------------------*)
  59.  
  60.     thing := read_tnc_data_str;
  61.  
  62.     (*-----------------------------------------------------------------------*)
  63.     (* Reset time out                                                        *)
  64.     (*-----------------------------------------------------------------------*)
  65.  
  66.     active_port^.cr_timeout := 0;
  67.  
  68.     (*-----------------------------------------------------------------------*)
  69.     (* Strip things                                                          *)
  70.     (*-----------------------------------------------------------------------*)
  71.  
  72.     strip_crlf(thing);
  73.  
  74.     (*-----------------------------------------------------------------------*)
  75.     (* Is phone ringing?                                                     *)
  76.     (*-----------------------------------------------------------------------*)
  77.  
  78.     IF thing = ring THEN
  79.       BEGIN;
  80.  
  81.         (*-------------------------------------------------------------------*)
  82.         (* Switch to channel 1                                               *)
  83.         (*-------------------------------------------------------------------*)
  84.  
  85.         active_tcb^.channel        := 1;
  86.         active_tcb^.port_chan_s[2] := '1';
  87.  
  88.         (*-------------------------------------------------------------------*)
  89.         (* Create a task                                                     *)
  90.         (*-------------------------------------------------------------------*)
  91.  
  92.         new_tcb := task_create(@user_start, user_stack_size);
  93.  
  94.         IF new_tcb <> NIL THEN
  95.           do_speed := TRUE
  96.         ELSE
  97.           BEGIN;
  98.             window_write_critical(prefix, 'Out of tasks for a ring answer');
  99.  
  100.             cmd_tnc(@disc_cmd, TRUE);
  101.  
  102.             active_port^.connected^[1] := NIL;
  103.           END;
  104.  
  105.         (*-------------------------------------------------------------------*)
  106.         (* Switch back to channel 0                                          *)
  107.         (*-------------------------------------------------------------------*)
  108.  
  109.         active_tcb^.channel        := 0;
  110.         active_tcb^.port_chan_s[2] := '0';
  111.  
  112.         (*-------------------------------------------------------------------*)
  113.         (* Delay                                                             *)
  114.         (*-------------------------------------------------------------------*)
  115.  
  116.         FOR i := 1 TO 20 DO
  117.           task_switch;
  118.  
  119.         EXIT;
  120.  
  121.       END;  (*---- End of handling ring -----------------------------*)
  122.  
  123.   END;
  124.